<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<html>
	 <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
        <meta name="format-detection" content="telephone=no">
        <meta charset="UTF-8">
        <meta name="description" content="Violate Responsive Admin Template">
        <meta name="keywords" content="Super Admin, Admin, Template, Bootstrap">
        <script src="<%=path %>/assets2/js/validation/validate.min.js"></script>
        <script src="<%=path %>/assets2/js/validation/validationEngine.min.js"></script>
        <script src="<%=path %>/assets2/js/validation/messages_zh.min.js"></script>
        <script src="<%=path %>/assets2/js/jquery.form.js"></script>
    </head>
	<form role="form">
	<input type="hidden" name="supplierGoodsId" id="supplierGoodsId" value="${param.supplierGoodsId }">
		<div class="row">
			<div class="col-md-4 form-group">
				<label>商品名称:</label> <label id="supplierGoodsName"></label>
			</div>
			<div class="col-md-4 form-group">
				<label>商品类别:</label>
				<label id="classifyId1"></label>
			</div>
			<div class="col-md-4 form-group">
				<label>商品价格:</label> <label id="supplierGoodsPrice"></label>
			</div>
		</div>
		<div class="clearfix"></div>
		<div class="row">
			<div class="col-md-4 form-group">
				<label>商品总量:</label> <label id="supplierGoodsStock"></label>
			</div>
			<c:if test="${param.state==1 }">
				<div class="col-md-4 form-group">
					<label>商品库存:</label> <label id="goodsStock"></label>
				</div>
			</c:if>
			<div class="col-md-4 form-group">
				<label>商品重量:</label> <label id="supplierGoodsWeight"></label>
			</div>
		</div>
		<div class="clearfix"></div>
		<div class="row">
			<div class="col-md-12 form-group">
				<label>商品规格:</label> <label id="supplierGoodsSize"></label>
			</div>
		</div>
		<div class="clearfix"></div>
		<div class="form-group m-b-15">
			<label>商品主图</label>
			<div class="row" id="goodsMainPhotoDiv">
			</div>
		</div>
		<div class="clearfix"></div>
		<div class="form-group m-b-15">
			<label>商品图片</label>
			<div class="row" id="photoDiv">
			</div>
		</div>
		<div class="clearfix"></div>
		<div class="form-group m-b-15">
			<label>商品描述</label>
			<label id="supplierGoodsIntro"></label>
		</div> 
	</form>

	<script type="text/javascript">
		(function(){
			if($("[class*='form-validation']")[0]) {
			    $("[class*='form-validation']").validationEngine();
			    $('body').on('click', '.validation-clear', function(e){
				e.preventDefault();
				$(this).closest('form').validationEngine('hide');
			    });
			}
		})();
		$(function(){
			$.ajax({
				 type:"POST",
		         url: "<%=path %>/supplier/getGoodsClassifyList",
		         success: function(data2,status,xhr){
		        	 $.ajax({
						 type:"POST",
				         url: "<%=path %>/supplier/getSupplierGoodsInfo?supplierGoodsId=${param.supplierGoodsId}",
				         success: function(data,status,xhr){
				        	$('#supplierGoodsName').html(data.supplierGoodsName);
				        	for(var i=0;i<data2.length;i++){
				        		if(data2[i].cassifyId==data.classifyId1){
				        			$('#classifyId1').html(data2[i].cassifyName);
				        			break;
				        		}
				        	 }
				        	$('#supplierGoodsPrice').html(data.supplierGoodsPrice);
				        	$('#goodsStock').html(data.goodsStock);
				        	$('#supplierGoodsStock').html(data.supplierGoodsStock);
				        	$('#supplierGoodsWeight').html(data.supplierGoogsWeight);
				        	$('#supplierGoodsSize').html(data.supplierGoodsSize);
				        	$('#goodsMainText').html(data.supplierGoodsThums);
				        	$('#goodsMainPhotoDiv').append('<div class="col-xs-3 col-md-2"><img class="img-responsive" src="<%=path %>/supplier/getApplyPhoto?photoUrl='+data.supplierGoodsThums+'" style="position:relative"></div>');
							var goodsImages=data.supplierGoodsImage.split(',');
							for(var i=0;i<goodsImages.length;i++){
								if(goodsImages[i]!=null&&goodsImages[i]!=''){
									var textFileId ='goodsText'+(i+1);
									$('#'+textFileId).val(goodsImages[i]);
									$('#photoDiv').append('<div class="col-xs-3 col-md-2" id="'+textFileId+'Div"><img class="img-responsive" src="<%=path %>/supplier/getApplyPhoto?photoUrl='+goodsImages[i]+'" style="position:relative"></div>');
								}
							}
				        	$('#supplierGoodsIntro').html(data.supplierGoodsIntro);
				         }
					})
		         }
			})
		})
		
	</script>
</html>